{extend name="public/basic" /}
{block name="body"}
<div class="container">
    <div class="login_box">
        <h1>Client Portal Login</h1>
            <form action="{:url('doLogin')}" method="post">
                <div>
                    <label>交易账号：</label>
                    <input type="text" name = "user_name" required>
                    <span class='red errorEmail'></span>
                </div>
                <div>
                    <label>密码：</label>
                    <input type="password" name = "user_pass" required>
                    <span class='red errorPassword'></span>
                </div>
                <div class="login">
                    <input type="button" value="登录" class='login'>
                    <a href="wjmm.html" style='display: none;'>忘记密码</a>
                </div>
        </form>
        <div>
            <h1>还未在XXX注册？</h1>
            <a href="{:url("front/registration/realreg")}">开设交易账户</a>
            <a href="{:url("front/registration/vilreg")}">Open Demo Account</a>
        </div>
    </div>
</div>

{/block}
{block name="css"}
<link rel="stylesheet" href="/static/css/title.css"/>
<link rel="stylesheet" href="/static/css/login.css"/>
{/block}
{block name="script"}
<script src="/static/js/other.js"></script>
<script src="/static/js/greenroom.js"></script>
<script>
    $('.login').on('click', function(){
        var data = $('.login_box form').serialize();
        $.ajax({
            url: '{:url('doLogin')}',
            type:'post',
            dataType:'json',
            data: data,
            success:function(msg){
                console.log(msg.code);
                if(msg.code == '0' || msg.code == 0) {
                     location.href = '{:url("front/personal/index")}';
                };
                if(msg.code == 1) {
                    $('.errorPassword').text('密码错误')
                };
                if(msg.code == undefined) {
                     $('.errorEmail').text('账号不正确')
                }
            }
        })    
    })
</script>
{/block}
